package flex.persistence {
	public class TemporalType extends AbstractType {
		protected static var localInstantiation:Boolean = false;
		
		private static var _DATE:TemporalType; 
		public static function get DATE():TemporalType {
			if(!_DATE) { 
				localInstantiation = true;
				_DATE = new TemporalType("DATE");
				localInstantiation = false;
			}
			return _DATE;
		} 
		
		private static var _TIMESTAMP:TemporalType; 
		public static function get TIMESTAMP():TemporalType {
			if(!_TIMESTAMP) { 
				localInstantiation = true;
				_TIMESTAMP = new TemporalType("TIMESTAMP");
				localInstantiation = false;
			}
			return _TIMESTAMP;
		} 

		private static var _TIME:TemporalType; 
		public static function get TIME():TemporalType {
			if(!_TIME) { 
				localInstantiation = true;
				_TIME = new TemporalType("TIME");
				localInstantiation = false;
			}
			return _TIME;
		} 

		public static function valueOf(name:String):TemporalType {
			for each(var val:TemporalType in values()) {
				if(val.name.toUpperCase() == name.toUpperCase()) return val;
			}
			return null;
		}
		
		public static function values():Array {
			return [DATE, TIMESTAMP, TIME];
		}
		
		public function TemporalType(name:String) {
			if(!localInstantiation) throw Error("Private constructor");
			this.name = name;
		}
		
	}
}